//
// Created by mio on 25-5-16.
//

#include <QResizeEvent>
#include <QVBoxLayout>

#include "PullerWgt.h"



PullerWgt::PullerWgt(EventLoop *loop, QWidget *parent) : QMainWindow(parent)
{
    this->setMinimumSize(400, 250);
    this->resize(800, 500);

    setWindowTitle("CloudAssistant"); // 窗口标题
    setWindowIcon(QIcon(":/UI/brown/center/favicon-32.ico")); // 窗口图标
    setStyleSheet("background-color:#121212"); // 设置窗口背景

    player_.reset(new AVPlayer(loop, this));
    QVBoxLayout *layout = new QVBoxLayout(this);
    layout->addWidget(player_.get());
    layout->setSpacing(0);
    layout->setContentsMargins(0, 0, 0, 0);
    this->setLayout(layout);
}

bool PullerWgt::Connect(QString ip, uint16_t port, QString code)
{
    return player_->Connect(ip, port, code);
}

void PullerWgt::StartPull() {
    player_->HandleStartStream("rtmp://127.0.0.1:1935/live/test");
}

void PullerWgt::resizeEvent(QResizeEvent *event) {
    player_->resize(event->size());
    QMainWindow::resizeEvent(event);
}

